more language updates
authorMichael Dale <dale@users.mediawiki.org>
Tue, 3 Nov 2009 06:26:20 +0000 (06:26 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Tue, 3 Nov 2009 06:26:20 +0000 (06:26 +0000)
js2/mwEmbed/mv_embed.js
js2/mwEmbed/tests/README [new file with mode: 0644]
js2/mwEmbed/tests/testLang.html
js2/remoteMwEmbed.js

index 7bf7d4c..a153a02 100644 (file)
@@ -294,14 +294,15 @@ if( !mv_embed_path ) {
                
                //a quick check to see if we need to send the msg via the 'parser'
                //(we can add more detailed check once we support more wiki syntax)
-               if(ms.indexOf('{{') === -1 && ms.indexOf('[') === -1){
+               if( ms.indexOf('{{') === -1 && ms.indexOf('[') === -1){
                        return ms;
                }
 
                //make sure we have the lagMagic setup:
+               //@@todo move to init
                $.lang.magicSetup();
                //send the msg key through the parser
-               pObj = $.parser.pNew( ms );
+               var pObj = $.parser.pNew( ms );         
                //return the transformed msg
                return pObj.getHTML();
        }
@@ -598,10 +599,12 @@ if( !mv_embed_path ) {
                                 */
 
                                // ~ probably a better algorithm out there / should mirror php parser flow ~
+                               //       (we are already running white-space issues ie php parse strips whitespace diffrently)
+                               
                                // ... but I am having fun with recursion so here it is...
                                // or at least mirror: http://www.mediawiki.org/wiki/Extension:Page_Object_Model
                                function rdpp ( txt , cn){
-                                       var node = {};
+                                       var node = {};                                  
                                        //inspect each char
                                        for(var a=0; a < txt.length; a++){
                                                if( txt[a] == '{' && txt[a+1] == '{' ){
@@ -630,7 +633,7 @@ if( !mv_embed_path ) {
                                /**
                                 * parse template text as template name and named params
                                 */
-                               function parseTmplTxt( ts ){
+                               function parseTmplTxt( ts ){                            
                                        var tObj = {};
                                        //Get template name:
                                        tname = ts.split('\|').shift() ;
@@ -645,14 +648,18 @@ if( !mv_embed_path ) {
                                                tObj["arg"] = tname.split(':').pop();
                                        }
 
-                                       js_log("TNAME::" + tObj["name"] + ' from:: ' + ts);     
-                                       
+                                       js_log("TNAME::" + tObj["name"] + ' from:: ' + ts);                                             
                                        var pSet = ts.split('\|');
-                                       pSet.splice(0,1);
+                                       pSet.splice(0,1);                                       
                                        if( pSet.length ){
                                                tObj.param = new Array();
-                                               for(var pInx in pSet){
+                                               for(var pInx in pSet){                                                  
                                                        var tStr = pSet[ pInx ];
+                                                       //check for empty param
+                                                       if(tStr==''){
+                                                               tObj.param[ pInx ] = '';
+                                                               continue;
+                                                       }
                                                        for(var b=0 ; b < tStr.length ; b++){
                                                                if(tStr[b] == '=' && b>0 && b<tStr.length && tStr[b-1]!='\\'){
                                                                        //named param
@@ -663,7 +670,7 @@ if( !mv_embed_path ) {
                                                                }
                                                        }
                                                }
-                                       }
+                                       }                                                       
                                        return tObj;
                                }
                                function getMagicTxtFromTempNode( node ){
@@ -764,7 +771,7 @@ if( !mv_embed_path ) {
                                //wikiText updates should invalidate pOut
                                if( this.pOut == ''){
                                        this.parse();
-                               }
+                               }                               
                                return this.pOut;
                        }
                };
@@ -1204,8 +1211,8 @@ window.onload = function () {
  * Store all the mwEmbed jQuery-specific bindings
  * (set up after jQuery is available).
  *
- * These functions are generaly are loaders that do the dynamic mapping of
- * dependencies for a given componet
+ * These functions are genneraly are loaders that do the dynamic mapping of
+ * dependencies for a given commponet
  * 
  *
  */
diff --git a/js2/mwEmbed/tests/README b/js2/mwEmbed/tests/README
new file mode 100644 (file)
index 0000000..7481623
--- /dev/null
@@ -0,0 +1,2 @@
+This folder contains stand alone tests of js2/mwEmbed components. 
+The tests folder does not need to be included or exposed in a production environment. 
\ No newline at end of file
index 3c6a7b4..64d152b 100644 (file)
@@ -8,8 +8,9 @@ td{
 }
 </style>
 <script type="text/javascript" >
+var scriptLoaderURID = 't10';
 //for just setting one or two to test at a time for debug
-var langKeyDebug = ['en'];
+var langKeyDebug = ['fr'];
 
 //shortLangKey is an array of at least one language from every group in cldrConverter.php
 var langKeyGroups = ['en','az', 'da', 'pt', 'fr', 'lv', 'ga','hr','cy','mk','mt','pl','sl'];
@@ -194,8 +195,8 @@ js2AddOnloadHook( function(){
                $j.each(langSet, function(na, langKey){                                 
                        js_log('load language key: ' + langKey);                        
                        //do a manual call to the script-lodaer:
-                       js_log('do load: ' + '../../../mwScriptLoader.php?class=$mw.testLang&urid=5&lang='+langKey );
-                       $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid=8&lang='+langKey, function(){
+                       js_log('do load: ' + '../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&lang='+langKey );
+                       $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&lang='+langKey, function(){
                                var o='';
                                o+='<tr><td colspan="6" height="20" style="font-size:large"><b>Lang:' + langKey + '</b></td></tr>';             
                                //now for each langage msg: 
@@ -235,15 +236,23 @@ js2AddOnloadHook( function(){
                                                                do_api_req({
                                                                        'data': {
                                                                                'action' : 'parse',
+                                                                               'uselang' : 'fr',
                                                                                'text' : '{{int:' + mKey + '|' + msgparam + '}}'
                                                                        },
                                                                        'url' : '../../../api.php'                                      
                                                                }, function( data ) {                                                   
                                                                        var t = '#'+ tkey ;                                                             
                                                                        if(data.parse && data.parse.text && data.parse.text['*']){
-                                                                               $j(t).html( data.parse.text['*'] );
+                                                                               $j(t).html( data.parse.text['*'] );                                                                             
+                                                                               var js_txt = $j.trim( $j(t + '_js').text().replace('\n', '') );
+                                                                               var php_txt = $j.trim( $j(t + ' p').text())
                                                                                //just get the part in the <p> to compare with js version
-                                                                               if( $j.trim( $j(t + ' p').html() )  != $j.trim( $j(t + '_js').html() ) ){                                                                       
+                                                                               if( js_txt != php_txt ){
+                                                                               var cat = $j.trim( $j(t + ' p').text() );
+                                                                               var dog =  $j.trim( $j(t + '_js').text() );                                                                                     
+                                                                                       if( cat == dog)
+                                                                                               alert('wtf');
+                                                                                       //debugger;                                                                     
                                                                                        $j(t).css('color', 'red');
                                                                                        failTest++;
                                                                                }else{
index 23fb0fa..43bf9b8 100644 (file)
@@ -6,7 +6,6 @@
 var urlparts = getRemoteEmbedPath();
 var mwEmbedHostPath = urlparts[0];
 var reqAguments = urlparts[1];
-
 addOnloadHook( function(){
        //only do rewrites if MV_EMBED / js2 is "off"
        if( typeof MV_EMBED_VERSION == 'undefined' ) {